package com.rgbgame.physics;

public class ShapeData {
	/** Total count of ShapeData objects, used to generate unique ids */
	static private int idCount = 0;
	/** Unique id */
	private int m_id;

	/** Group membership flags */
	private int m_groupFlags;
	
	/** 
	 * Type - given as int so that we don't have incredible enum-bloat,
	 * since this way many different body types can re-use the same shape
	 * type markers.
	 */
	private int m_type;
	static public int UNKNOWN = -1;
	
	public ShapeData() {
		m_id = idCount++;
		m_type = UNKNOWN;
	}
	
	public int getType() {
		return m_type;
	}
	
	public void setType(int newType) {
		m_type = newType;
	}
	
	public int getGroupFlags() {
		return m_groupFlags;
	}
	
	public void setGroupFlags(int groupFlags) {
		m_groupFlags = groupFlags;
	}
	
	public boolean isInGroup(int groupNum) {
		int toCheck = 1<<groupNum;
		return (m_groupFlags & toCheck) == toCheck;
	}
	
	public void addToGroup(int groupNum) {
		assert(groupNum < Actor.MAX_GROUPS);
		int tmp = 1<<groupNum;
		m_groupFlags |= tmp;
	}
	
	public void removeFromGroup(int groupNum) {
		assert(groupNum < Actor.MAX_GROUPS);
		int tmp = 1<<groupNum;
		m_groupFlags &= ~tmp;
	}
	
	public int getID() {
		return m_id;
	}
	
	static public void resetStatics() {
		idCount = 0;
	}
}
